/** ****************************************************************************
@addtogroup SHIP_RFIC_DRIVER
@{
*******************************************************************************/

#include "stdinc.h"
#include "spi.h"


uint8_t SPI_TxRx0(uint8_t ch) {
    // 发送数据
	SPI_SendData(ch);
    // When BSY is set, the SPI is busy communicating.
	while(SPI_GetFlagStatus(SPI_FLAG_BSY) == SET);
    // 返回收到的数据
	return SPI_ReceiveData();
}

uint8_t SPI_TxRx1(FUNC_void_u8 sck, FUNC_void_u8 mosi, FUNC_u8_void miso, uint8_t ch) {
	uint8_t i;
	uint8_t inch = 0;

	sck(0);
	for(i=0; i<8; i++) {
		mosi(ch & 0x80);
		ch <<= 1;
		sck(1);
		inch <<= 1;
		inch += miso();
		sck(0);
	}

	return inch;
}


/// @}
